package projet_v1.items.weapons;

import java.util.HashMap;

import projet_v1.Breed;
import projet_v1.Character;
import projet_v1.Item;
/**
 * This class manages weapons.
 * 
 * @author Alexis Laurent
 *
 */
public abstract class Weapon extends Item {

	// the type of the weapon
	protected CategoryWeapon category;
	// determine the possibility to miss the attack
	protected double accurancy;
	// contains the damages caused by the weapon according to the breed of the character
	protected HashMap<Breed,Integer> damages;
	// if the weapon needs ammo
	protected boolean needsAmmo;
	
	/**
	 * Construtor of the Shotgun
	 * 
	 * @param cat
	 * 			: the category of the weapon
	 * 
	 * @param acc
	 * 			: the accurancy of the weapon
	 */
	Weapon(CategoryWeapon cat, double acc) {
		super(Item.CODE_WAR_ITEM);
		category = cat;
		accurancy = acc;
		damages = null;
		needsAmmo = false;
	}
	
	/**
	 * Construtor of the Shotgun
	 * 
	 * @param cat
	 * 			: the category of the weapon
	 * 
	 * @param acc
	 * 			: the accurancy of the weapon
	 * 
	 * @param ndsammo
	 * 			: if the weapon needs ammo
	 */
	Weapon(CategoryWeapon cat, double acc, boolean ndsammo) {
		super(Item.CODE_WAR_ITEM);
		category = cat;
		accurancy = acc;
		damages = null;
		needsAmmo = ndsammo;
	}
	
	
	
	//Accessors
	
	public CategoryWeapon getCategory() {
		return category;
	}


	public void setCategory(CategoryWeapon category) {
		this.category = category;
	}


	public double getAccurancy() {
		return accurancy;
	}


	public void setAccurancy(double accurancy) {
		this.accurancy = accurancy;
	}


	public HashMap<Breed, Integer> getDamages() {
		return damages;
	}


	public void setDamages(HashMap<Breed, Integer> damages) {
		this.damages = damages;
	}
	
	/**
	 * To get the damages for a specific breed
	 * 
	 * @param b
	 * 			: the breed
	 * 
	 * @return the damage for a specific breed
	 */
	public int getDamages(Breed b) {
		return damages.get(b);
	}


	@Override
	public void use(Character c) {
		int dam = hit(c);
		c.reduceHealthPoints(dam);
		System.out.println("Damages : " + dam + " --> " + c.getBreed() + " --> " + this.getCategory());
	}
	
	public abstract int hit(Character c);
	
	/**
	 * @return if the weapon has again some ammo
	 */
	public boolean hasAmmo() {
		return needsAmmo;
	}
	
}
